package com.changgou.config.service.impl;

import com.changgou.config.dao.SysDictDataMapper;
import com.changgou.config.dao.SysDictTypeMapper;
import com.changgou.config.pojo.DictData;
import com.changgou.config.pojo.DictType;
import com.changgou.config.service.ISysDictService;
import com.changgou.constants.SysConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Jiang Yilin
 * @title: SysDictServiceImpl
 * @projectName changgou_parent
 * @description: TODO
 * @date 2020/3/618:10
 */
@Service
public class SysDictServiceImpl implements ISysDictService {

    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    @Autowired
    private SysDictDataMapper sysDictDataMapper;



    @Override
    public List<DictType> findAll() {

        DictType dictType = new DictType();
        dictType.setStatus(SysConst.STATUS_AVAILABLE);

        List<DictType> select = sysDictTypeMapper.select(dictType);

        return select;
    }

    @Override
    public List<DictData> findByType(String type) {
        DictData dictData = new DictData();
        dictData.setStatus(SysConst.STATUS_AVAILABLE);
        dictData.setDictType(type);
        List<DictData> select = sysDictDataMapper.select(dictData);
        return select;
    }

    @Override
    public DictData findById(String code) {
        return sysDictDataMapper.selectByPrimaryKey(code);
    }

    @Override
    public DictType findTypeById(String dict_id) {
        return sysDictTypeMapper.selectByPrimaryKey(dict_id);
    }
}
